﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Idte.Core.Infrastructure.Repository
{
    //[CollectionDataContract(ItemName = "ObjectValue")]
    [CollectionDataContract(Name = "ChangedStateCollection",
        ItemName = "StateChangedEntities", KeyName = "StateChanged", ValueName = "ChangedEntities")]
    public class ChangedStateCollection : Dictionary<EntityState, ObjectList> { }

    [CollectionDataContract(ItemName = "ObjectValue")]
    public class ObjectList : List<object> { }

    [DataContract(IsReference = true)]
    public class ChangeTracker
    {
        private ChangedStateCollection _changedStateCollection = new ChangedStateCollection();
        [DataMember]
        public ChangedStateCollection ChangedStateCollection
        {
            get
            {
                if (_changedStateCollection == null)
                {
                    _changedStateCollection = new ChangedStateCollection();
                }
                return _changedStateCollection;
            }
        }
    }
}
